package com.cw1.principle.liskov;

public class LisKov {
    public static void main(String[] args) {
        A a = new A();
        System.out.println("11 - 3 =" + a.func1(11,3));
        System.out.println("1 - 8 =" + a.func1(1,8));

        System.out.println("--------------------");
        B b = new B();// b类这里重写的方法func1、减法弄成了减法
        System.out.println("11 - 3 =" + b.func1(11, 3) );
        System.out.println("1 - 8 =" + b.func1(1,8));
        System.out.println("11 + 3 + 9 =" + b.func2(11, 3));
    }
}

class A {
    public int func1 (int a , int b){
        return a - b;
    }
}

class B extends A{
    public int func1 (int a , int b){
        return a + b;
    }

    public int func2(int a ,int b){
        return func1(a,b) + 9;
    }
}